let req = (url,data,type='get',async) => {
    return new Promise((resolve, reject) => {
        $.ajax({
            url: 'http://localhost:8001'+url,
            data,
            type,
            dataType: 'json',
            async,
            success: data => resolve(data),
            error: e => reject(e)
        })
    })
}

//获取地址栏参数
function getParameter(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}


//验证登录
function validateLogin() {
    let user = JSON.parse(sessionStorage.getItem('user'))
    if(!user){
        location.href = 'login.html'
    }
}




